Page({

  /**
   * 页面的初始数据
   */
  data: {
    musicUrl:"",
    detail:[],
    comments:[],
    total: "",
    recommends:[]
  },

  getMusic(videoId){
    let that = this;
    wx.request({
      url: 'https://autumnfish.cn/song/url?id=' + videoId,
      success(res){
        //console.log(res.data.data[0].url)
        that.setData({
          musicUrl: res.data.data[0].url
        })
      }
    })
  },

  getMusicDetail(videoId) {
    let that = this;
    wx.request({
      url: 'https://autumnfish.cn/song/detail?ids=' + videoId,
      success(res) {
        //console.log(res.data.songs[0])
        that.setData({
          detail: res.data.songs[0]
        })
      }
    })
  },

  getComments(videoId) {
    let that = this;
    wx.request({
      url: 'https://autumnfish.cn/comment/music?id=' + videoId,
      success(res) {
        //console.log(res.data)
        that.setData({
          comments: res.data.hotComments,
          total: res.data.total
        })

      }
    })
  },

  getRecommend(videoId) {
    let that = this;
    wx.request({
      url: 'https://autumnfish.cn/simi/song?id=' + videoId,
      success(res) {
        console.log(res.data.songs)
        that.setData({
          recommends: res.data.songs
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let videoId = options.id;
    this.getMusic(videoId);
    this.getMusicDetail(videoId);
    this.getComments(videoId);
    this.getRecommend(videoId);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})